/*
 * Copyright (C) 2010 Imavis Srl
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.imavis.avimuxer;

import java.io.File;
import java.io.IOException;

/**
 * Configures and creates a {@link Muxer} instance.
 * <p>
 * A {@code MuxerBuilder} implementation may have several methods to
 * configure the resulting muxer. After the configuration is done, a
 * muxer is created by calling the {@link #open(java.io.File)} method.
 * <p>
 * A single instance can be used to create several {@link Muxer} objects with
 * the same configuration.
 *
 * @author Andrea Gualano
 */
public interface MuxerBuilder {
    /**
     * Creates a muxer instance and writes headers to the output file.
     * <p>
     * This method creates a new {@link Muxer} object with the desired
     * configuration, opens the given file for writing and starts writing to
     * the file. Any required headers may be written at this time.
     *
     * @param file the output file
     * @return an open {@link Muxer}
     * @throws IllegalStateException if the configuration is insufficient or
     * inconsistent.
     * @throws IOException if an I/O error occurs.
     */
    public Muxer open(File file) throws IllegalStateException, IOException;
}
